package com.example.smart_community.controller;

import com.example.smart_community.po.Notice;
import com.example.smart_community.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/notice")
public class NoticeController {
    @Autowired
    private NoticeService noticeService;
    @GetMapping("/selectById")
    public Notice selectById(Integer id){
        return noticeService.selectById(id);
    }
    @GetMapping("/selectAll")
    public List<Notice> selectAll(){
        return noticeService.selectAll();
    }
    @GetMapping("/selectByTileAndTime")
    public List<Notice> selectByTileAndTime( String title,  String time){
        return noticeService.selectByTileAndTime(title, time);
    }
    @GetMapping("/updateNotice")
    public int updateNotice( Integer id,String title, String content, String time,String person){
        return noticeService.updateNotice(id, title, content, time, person);
    }
    @GetMapping("/insertNotice")
    public int insertNotice(String title,String content,String time,String person){
        return noticeService.insertNotice(title, content, time, person);
    }
    @GetMapping("/deleteNotice")
    public int deleteNotice(Integer id){
        return noticeService.deleteNotice(id);
    }
}
